package datastructure.selfexercise;

import java.util.Arrays;

/**
 * @Author Gan
 * @Date 2021/5/12 18:57
 * @Description:
 */
public class Junit04 {
    public static void main(String[] args) {
        int[] nums = new int[]{3,6,9,1};
        System.out.println(maximumGap(nums));
    }
    private static int maximumGap(int[] nums) {
        if(nums.length < 2)
            return 0;
        Arrays.sort(nums);
        int maxValue = 0;
        for(int i = 0,j =  1;j < nums.length;i++,j++){
            int Value = nums[j] - nums[i];
            if(Value > maxValue){
                maxValue = Value;
            }
        }
        return maxValue;
    }
}
